package com.ioudi.digu.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

public class FavoriteDAO extends GeneralDAO
{
	
	public List checkFavorite(String user, List ids)
    {
    	 Session s = this.getSession();
    	 List list = null;
         try
         {
         	s.beginTransaction();
         	String sql = "select ship.message.messageId from FavoriteShip " +
         			"ship where ship.user = ? and ship.message.messageId in (:ids)" ;
         	Query query = s.createQuery(sql);
         	query.setString(0, user);
         	query.setParameterList("ids", ids);
         	list = query.list();
         	s.getTransaction().commit();
         }
         catch(Exception e)
         {
        	 list = null;
         	 s.getTransaction().rollback();
         }
         finally
         {
         	s.close();
         }
     	return list;
    }
}
